﻿using DotNetty.Transport.Channels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace AiMei.Redis.Core
{
    public class RedisHandle : SimpleChannelInboundHandler<RedisObject>
    {
        //ConcurrentDictionary
        protected override void ChannelRead0(IChannelHandlerContext ctx, RedisObject msg)
        {
            //Console.WriteLine(msg.ToString());
            //Utils.TaskQueue.Enqueue(msg);
            if (Utils.TryDequeue(out TaskCompletionSource<RedisObject> taskCompletionSource))
            {
                taskCompletionSource.SetResult(msg);
            }
            else
            {
            }
        }
    }
}
